import { Component, OnInit } from '@angular/core';
import { UserService } from '../../services/user/user.service';

@Component({
  selector: 'app-head',
  templateUrl: './head.component.html',
  styleUrls: ['./head.component.css']
})
export class HeadComponent implements OnInit {

  userStatus:boolean = false;
  user:object = {};

  constructor(private us:UserService) { }

  ngOnInit() {
    // 判断用户有没有登陆
      this.us.checkLogin().subscribe((data)=>{
          let result = data.json();
          this.userStatus = result.status;
          // console.log(result);
          // console.log(result.status);
          // console.log(result.user);
          if(result.status){
            // this.userStatus = result.status;
            this.user = result.msg;
            console.log(this.user);
            return;
          }
          
          // this.userStatus = result.status;
          this.user = {};
      });

  }
 

  quit(){
          this.us.quit().subscribe((data)=>{
          // let result = data.json();
          // this.userStatus = result.status;
          // 初始换页面
          this.userStatus = false;
          this.user = {};
      });
  }
  
  

}
